﻿@page "/admin"

@using  Microsoft.AspNetCore.Identity
@using BlazorApp15.Data
@using BlazorStrap

@inject RoleManager<IdentityRole>   roleManager
@inject UserManager<IdentityUser> userManager





    <h3>Admin component</h3>

    <p>
        this page is only accessible to users with 'Admin' Roles
    </p>




    @code {

        private string newRole { get; set; }

        private IEnumerable<IdentityRole> identityRoles;
        private IEnumerable<IdentityUser> identityUsers;


        private void CreateRole(string RoleName)
        {
            IdentityRole role = new IdentityRole(RoleName);
            roleManager.CreateAsync(role);

        }

        private void  CreateUser(string userName, string email)
        {
            IdentityUser user = new IdentityUser(userName);
            user.Email = email;

            var result =  userManager.CreateAsync(user, "Pass0123@");

            if (result.IsCompletedSuccessfully)
            {
               
            }
        }


        protected override void OnInitialized()
        {
            identityRoles = roleManager.Roles.ToList();
            identityUsers = userManager.Users.ToList();
        }

}
